package com.zbbt.sportslottery.ui.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zbbt.sportslottery.util.KeyUtil;
import com.zbbt.sportslottery.util.LogUtil;
import com.zbbt.sportslottery.util.UmengUtil;

public class BaseFragment extends Fragment {
	protected String TAG = getClass().getSimpleName();
	protected Activity context;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		context = activity;
		LogUtil.printI("BaseFragment", TAG + "->onAttach");
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		LogUtil.printI("BaseFragment", TAG + "->onCreate");
	}

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		LogUtil.printI("BaseFragment", TAG + "->onCreateView");
		return super.onCreateView(inflater, container, savedInstanceState);
	}

	@Override
	public void onActivityCreated(@Nullable Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		LogUtil.printI("BaseFragment", TAG + "->onActivityCreated");
	}

	@Override
	public void onStart() {
		super.onStart();
		LogUtil.printI("BaseFragment", TAG + "->onStart");
	}

	@Override
	public void onResume() {
		super.onResume();
		LogUtil.printI("BaseFragment", TAG + "->onResume");
		if (!TAG.equals("ChildHomeFragment")) {
			UmengUtil.onPageStart(TAG);
		}
	}

	@Override
	public void onPause() {
		super.onPause();
		LogUtil.printI("BaseFragment", TAG + "->onPause");
		if (!TAG.equals("ChildHomeFragment")) {
			UmengUtil.onPageEnd(TAG);
		}
	}

	@Override
	public void onStop() {
		super.onStop();
		LogUtil.printI("BaseFragment", TAG + "->onStop");
	}

	@Override
	public void onDestroyView() {
		super.onDestroyView();
		LogUtil.printI("BaseFragment", TAG + "->onDestroyView");
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		LogUtil.printI("BaseFragment", TAG + "->onDestroy");
	}

	@Override
	public void onDetach() {
		super.onDetach();
		LogUtil.printI("BaseFragment", TAG + "->onDetach");
	}

	/**
	 * 
	 * @MethodName:goActivity
	 * @Description: 跳转到Activity
	 * @author：LiZhimin
	 * @param clazz
	 *            void
	 */
	protected void goActivity(Class<?> clazz) {
		Intent intent = new Intent(context, clazz);
		startActivity(intent);
	}
	
	protected void goActivity2(Class<?> clazz,int gotoType,int gotonum ) {
		Intent intent = new Intent(context, clazz);
		intent.putExtra(KeyUtil.GotoType, gotoType);
		intent.putExtra(KeyUtil.FragmentKey, gotonum);
		startActivity(intent);
	}
}
